import gulp from 'gulp';
import del from 'del';
import plugins_ from 'gulp-load-plugins';
import config_ from '../taskconfig';
var plugins = plugins_();
var config = config_.js;


//es6--->es5
gulp.task('js:build',() => {
    return gulp.src(config.src)
           .pipe(plugins.babel())
           .pipe(gulp.dest(config.build))
           .pipe(plugins.uglify())//压缩
           .pipe(plugins.concat('sc.js'))//合并
           .pipe(plugins.rename({suffix: '.min'}))
           .pipe(gulp.dest(config.build));
});

//js发生变化立即编译
gulp.task('js:watch', () => {
    return gulp.watch(config.all, ['js:build']);
});

//清空build文件夹下的js文件
gulp.task('js:clean', (cb) => {
	 return del([config.build], cb);
});

//js代码检查
gulp.task('js:jsLint',() => {
	 gulp.src('./src/js/app/*.js')
	     .pipe(plugins.jshint())
	  //   .pipe(plugins.jshint.reporter()); // 输出检查结果
});

